package com.xxxy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxxy.dao.AdministrativeClassDao;
import com.xxxy.dao.FacultyDao;
import com.xxxy.dao.StudentDao;
import com.xxxy.model.AdministrativeClass;
import com.xxxy.model.Faculty;
import com.xxxy.model.Student;
import com.xxxy.service.AdministrativeClassService;
import com.xxxy.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author sjh
 * @date 2022/2/1 16:20
 */
@Service
public class AdministrativeClassServiceImpl extends ServiceImpl<AdministrativeClassDao, AdministrativeClass> implements AdministrativeClassService {

    @Autowired
    AdministrativeClassDao administrativeClassDao;

    @Autowired
    StudentService studentService;

    @Override
    public Map<Integer,String> getItemMap(){
        Map<Integer,String> map = new HashMap<>();
        List<AdministrativeClass> list = administrativeClassDao.selectList(null);
        for (int i=0; i<list.size(); i++){
            AdministrativeClass administrativeClass = list.get(i);
            map.put(administrativeClass.getId(),administrativeClass.getClassName());
        }
        return map;
    }

    @Override
    public AdministrativeClass getByName(String administrativeClassName) {
        LambdaQueryWrapper<AdministrativeClass> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(AdministrativeClass::getClassName, administrativeClassName);
        AdministrativeClass administrativeClass = administrativeClassDao.selectOne(lambdaQueryWrapper);
        return administrativeClass;
    }

    @Override
    public List<AdministrativeClass> getAdministrativeClassByFacultyId(Integer facultyId) {
        LambdaQueryWrapper<AdministrativeClass> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(AdministrativeClass::getFacultyId, facultyId);
        return administrativeClassDao.selectList(lambdaQueryWrapper);
    }

}
